#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main() {

	int i, r;
	char n[10000];
	scanf("%d", &r);
	for (i = 0; i < r; i++) {
		scanf("%s", n);
		int j = 0; int count = 0;
		while (n[j] != '\0') {
			if (n[j] == '2') count++;
			j++;
		}
		printf("count=%d\n", count);
	}

	return 0;
}
//1094